package com.csxh.bookstore.filter;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;

public class AuthInterceptor extends MethodFilterInterceptor {

	@Override
	protected String doIntercept(ActionInvocation invocation) throws Exception {
		System.out.println(invocation.getProxy().getMethod());
		System.out.println("befor");

		if (null == ServletActionContext.getRequest().getSession().getAttribute("user")) {
			return Action.LOGIN;
		}

		System.out.println("after");
		String result = invocation.invoke();

		return result;
	}

}
